package cn.wuqingna.legendgem.attribute.imp

import cn.wuqingna.legendgem.attribute.IAttribute
import org.bukkit.Bukkit
import org.bukkit.entity.LivingEntity
import org.serverct.ersha.api.AttributeAPI
import java.util.*

object AttributePlus: IAttribute {
    override fun add(uuid: UUID, source: String,  list: List<String>) {
        val data = AttributeAPI.getAttrData(Bukkit.getEntity(uuid) as LivingEntity)
        AttributeAPI.addSourceAttribute(data, source, list)
    }

    override fun remove(uuid: UUID, source: String) {
        val data = AttributeAPI.getAttrData(Bukkit.getEntity(uuid) as LivingEntity)
        data.takeApiAttribute(source)
    }

    override fun upData(uuid: UUID) {
        val entity = Bukkit.getEntity(uuid)
        if (entity != null)
        AttributeAPI.updateAttribute(entity as LivingEntity)
    }
}